package son.nt.act1;


import java.util.ArrayList;

import son.nt.R;
import son.nt.adapter.ItemAreaAdapter;
import son.nt.entities.ItemDemo;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class AreaActivity extends Activity implements OnItemClickListener{
	private static final String ACT2_LISTVIEW_CUSTOM = ".act2.ListviewCustom";
	private Context mContext = null;
	private ListView lv;
	private ArrayList<ItemDemo> list = null;
	ItemAreaAdapter adapter = null;
	Handler mHandler = new Handler();
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.act1_area);
		mContext = this;
		lv = (ListView) findViewById(R.id.lvArea);
		list = new ArrayList<ItemDemo>();
		list.add(new ItemDemo(".act2.ContextMenuActivity", "Context menu", "13/9/2012"));
		list.add(new ItemDemo(".act2.WebviewJavaScriptActivity", "web view javascript", "11/9/2012"));
		list.add(new ItemDemo(".act2.Act2EncodeHtmlActivity", "encode decode html", "11/9/2012"));
		list.add(new ItemDemo(".act2.AnimationActivity", "Animation", "23/8/2012"));
		list.add(new ItemDemo(ACT2_LISTVIEW_CUSTOM, "custom listview", "6/8/2012"));
		list.add(new ItemDemo(".act2.FileActivity", "Save - delete file", "11/8/2012"));
		list.add(new ItemDemo(".act2.Act2LifeCycleActivity", "Android life cycle", "14/8/2012"));
		list.add(new ItemDemo(".act2.Act2HttpRequestActivity", "Http request get json", "15/8/2012"));
		adapter = new ItemAreaAdapter(mContext, list);
		lv.setAdapter(adapter);
		lv.setOnItemClickListener(this);
	}
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		ItemDemo demo = list.get(position);
		Intent intent = new Intent();
		ComponentName mComponentName = new ComponentName(mContext.getApplicationInfo()
				.packageName, mContext.getApplicationInfo().packageName + demo.getName());
		intent.setComponent(mComponentName);
		startActivity(intent);
//		overridePendingTransition(R.anim.pull_in_from_left, R.anim.hold);
	}


}
